package library;

import library.user.AdminUser;
import library.user.NormalUser;
import library.user.User;

import java.util.Scanner;

//程序入口
public class Main {
    //让用户输入自己的身份
    private static User login() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您的名字：");
        String name = scanner.next();
        System.out.println("请输入您的身份：（1.普通用户，2.管理员）");
        int role = scanner.nextInt();
        if (role == 1) {
            return new NormalUser(name);
        }else if (role == 2) {
            return new AdminUser(name);
        }else {
            System.out.println("输入错误！！！");
            return null;
        }
    }

    public static void main(String[] args) {
        //1.创建书记管理对象
        BookList bookList = new BookList();
        //2.创建用户对象
        User user = login();
        //3.创建一个主循环
        while (true) {
            //4.先显示用户对应菜单
            int choice = user.menu();
            //5.根据序号，执行对应操作
            user.work(choice,bookList);
        }
    }
}
